package com.bluesky.plum.uimodels.standard.components.containers.window;

import com.bluesky.plum.uimodels.standard.StandardUIComponentType;
import com.bluesky.plum.uimodels.standard.components.containers.Panel;
import com.bluesky.plum.uimodels.standard.components.menu.MenuBar;

/**
 * It is a special window class. it will has its logo,title,head panel, content
 * panel, even navigate panel,...<todo>
 * 
 * @author HZ00260
 * 
 */
public class MainWindow extends Window {

	protected Panel headPanel;
	protected MenuBar menuBar;

	protected WindowManager manager;

	public MainWindow() {
		super();

		// it is responsible for main window to create a window manager
		manager = new WindowManager();

		setWindowManager(manager);

		// register itself
		manager.register(this);

	}

	@Override
	protected void init() {
		super.init();

		headPanel = (Panel) uiComponentBuilder
				.createNonFieldComponent(StandardUIComponentType.Panel);
		
		//the contentPanel is created in the super class Window
//		contentPanel = (Panel) uiComponentBuilder
//				.createNonFieldComponent(StandardUIComponentType.Panel);

		headPanel.setName("headPanel");
		contentPanel.setName("contentPanel");

		addChildComponent(headPanel);
		//addChildComponent(contentPanel);
	}

	public Panel getHeadPanel() {
		return headPanel;
	}

	public void setHeadPanel(Panel headPanel) {
		if (this.headPanel != null)
			removeChildComponent(this.headPanel);

		this.headPanel = headPanel;
		addChildComponent(headPanel);
	}

	public MenuBar getMenuBar() {
		return menuBar;
	}

	public void setMenuBar(MenuBar menuBar) {
		if (this.menuBar != null)
			removeChildComponent(this.menuBar);

		this.menuBar = menuBar;

		addChildComponent(menuBar);
	}

	public void setContentPanel(Panel contentPanel) {
		if (this.contentPanel != null)
			removeChildComponent(this.contentPanel);

		this.contentPanel = contentPanel;
		addChildComponent(contentPanel);
	}

	public WindowManager getManager() {
		return manager;
	}

	public void setManager(WindowManager manager) {
		this.manager = manager;
	}

}
